package com.dfrz.controller;

import com.dfrz.entity.MyCollection;
import com.dfrz.entity.Result;
import com.dfrz.service.MyCollectionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 29877
 */
@RestController
public class MyCollectionController {
    @Resource
    private MyCollectionService myCollectionService;

    // 番剧页获取收藏的视频信息
    @GetMapping("/collections")
    public Result selectCollection(Integer uid, Integer page){
        List<MyCollection> collections=myCollectionService.selectcollections(uid,page);
        return Result.success(collections);
    }
    //个人中心获取收藏的视频信息
    @GetMapping("/collections2")
    public  Result selectCollection2(Integer uid,Integer page){
        List<MyCollection> collections=myCollectionService.selectcollections2(uid,page);
        return Result.success(collections);
    }

    //进入详情页判断该视频是否被登录的用户收藏
    @GetMapping("/collectionstatus")
    public Result collectionstatus(Integer uid,Integer vid){
        Boolean flag=myCollectionService.collectionstatus(uid,vid);
        return Result.success(flag);
    }
    //追番
    @GetMapping("/togglecollectionstatus")
    public Result togglecollectionstatus(Integer uid,Integer vid){
        Boolean flag=myCollectionService.collectionstatus(uid,vid);
        if(flag){
            myCollectionService.delectcollection(uid,vid);
        }else {
            myCollectionService.addcollection(uid,vid);
        }
        return Result.success(flag);
    }
}
